<template>
  <div>
    <h2>子组件2</h2>
    <button @click="sendToy">
      发送toy数据
    </button>
  </div>
</template>

<script lang="ts" setup>
import emitter from '@/utils/emitter'
import { ref, onBeforeUnmount } from 'vue'
let toy = ref('奥特曼')
function sendToy() {
  emitter.emit('send-toy', toy.value)
}
onBeforeUnmount(() => {
  emitter.off('send-toy')
})
</script>

<style lang="scss" scoped></style>
